<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
	String basePath = request.getContextPath();
	String path = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+basePath+"/";
	request.setAttribute("path",path);
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
	<meta name="format-detection" content="telephone=no,address=no,email=no"/>
	<meta name="keywords" content="" />
	<meta name="description" content="" />
	<title>注册</title>
	<script type="text/javascript" src="${path}/school/js/jquery1.12.js"></script>
	<script type="text/javascript" src="${path}/js/jquery-2.1.1.min.js"></script>
	<link href="${path}/school/css/style.css" rel="stylesheet" media="all">
	<link rel="shortcut icon" href="${path}/school/img/favicon.png">
</head>
<body>
	<header class="top_header">
		<h1><a href="./kaPersonal" class="go_back"></a><span class="black_text">找回密码</span></h1>
	</header><!-- header -->
	<div class="content_wrap login_register" id="login_wrap">
		<div class="logo_wrap"><a href="#"><img src="${path}/school/img/logo02.png"></a></div><!-- logo_wrap -->
		<form id="form1" name="form1" method="post" action="${path}/kaUpdatePwd" class="logreg_form">
			<input id="captcha" name="captcha" style="display: none" value="${captcha}">
			<input id="resp" name="resp" style="display: none" value="${resp}">
			<p class="form_txt">
				<input class="num_input" placeholder="输入手机码" type="number" name="phone" id="dn" required  style="color:#999999" >
				<input class="clear_input" type="button" id="cls" value="" onclick="document.getElementById('dn').value = '';" />
			</p>	
			<p class="form_txt zc_txt">
				<input placeholder="输入短信验证码" type="number" name="zc" id="zc" required onFocus="if(value==defaultValue){value='';this.style.color='#000'}" onBlur="if(!value){value=defaultValue;this.style.color='#999'}" style="color:#999999" >
				<input class="zc_but" id="zc_but" type="button" value="| 获取验证码" onclick="captchasend(this)"/>
			</p>
			<p class="form_txt">
				<input class="num_input" placeholder="输入新密码" type="text" name="password" id="mm" required onFocus="if(value==defaultValue){value='';this.style.color='#000'};this.type='password'" onBlur="if(!value){value=defaultValue;this.style.color='#999'}" style="color:#999999" >
				<input class="clear_input" type="button" id="cls" value="" onclick="document.getElementById('mm').value = '';" />
			</p>
<!-- 			<p class="form_txt">
				<input class="num_input" placeholder="输入新密码" type="password" name="password2" id="mm2" required onFocus="if(value==defaultValue){value='';this.style.color='#000'}" onBlur="if(!value){value=defaultValue;this.style.color='#999'}" style="color:#999999" >
				<input class="clear_input" type="button" id="cls" value="" onclick="document.getElementById('mm2').value = '';" />
			</p>		 -->	
			<p class="login_button">
				<input class="register_but" id="register_but" type="button" value="确定" onclick="updatePwd();"/>
				<span class="clear"></span>
			</p>
        </form>
	</div><!-- content_wrap -->

	<div class="footer_copyright">
		<p><span>苏州知行合一网络科技有限公司</span>提供技术支持，版权所有</p>
	</div><!-- footer_copyright -->

	
</body>
<script>
    function updatePwd() {
        var yzm = document.getElementById("zc").value;
        var password = document.getElementById("mm").value;
        if (password==""){
            alert("密码不能为空!");
        }
        if (yzm == "") {
            alert("验证码不能为空!");
        }else {
            document.getElementById("form1").submit();
        }
		/* 查出resp的值并弹框  */
    }
    var InterValObj; //timer变量，控制时间
    var count = 60; //间隔函数，1秒执行
    var curCount;//当前剩余秒数
    function captchasend() {
        curCount = count;
        var phone = document.getElementById("dn").value;
        //alert(phone);
		/*var partten = /^(?:13\d|15[89])-?\d{5}(\d{3}|\*{3})$/;*/
        var partten = /^1[3|4|5|7|8][0-9]\d{4,8}$/
        if (phone == "" || !partten.test(phone)) {
            alert("号码不正确!");
        } else {

            $("#zc_but").attr("disabled", "true");
            $("#zc_but").val("重新获取(" + curCount + ")");
            InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一次
            $.ajax({
                type: 'post',
                url: "${path}/captcha_sends_forget_pwd",
                data: {"phone": phone},
				/*contentType: 'application/json',
				 dataType: 'json',*/
                success: function (msg) {
					/*console.log(msg);
					 if (msg.code == 200) {
					 self.get();
					 self.hidelayout();
					 }*/
//					alert("获取验证码成功 请稍后。。");
                }
            })
        }


    }
    //timer处理函数
    function SetRemainTime() {
        if (curCount == 0) {
            window.clearInterval(InterValObj);//停止计时器
            $("#zc_but").removeAttr("disabled");//启用按钮
            $("#zc_but").val("重新获取验证码");
        }
        else {
            curCount--;
            $("#zc_but").val("重新获取(" + curCount + ")");
        }
    }
  /*  function checkForm() {
        var flag = true;
        var resp = form1.resp.value;
        if (resp != "null"&& resp!=null&&resp!="") {
            if (resp != 'resp') {
                alert(resp);
                flag = false;
            }
        }
        return flag;
    }*/


    $(window).load(function() {
        var resp = $('#resp').val()
        $('#resp').val(''); 
        $('#dn').val(''); 
        $('#zc').val(''); 
        $('#mm').val(''); 
        if (resp != "null"&& resp!=null&&resp!="") {
            if (resp != 'resp') {
                alert(resp);
            }
        }
    });
</script>
</html>